import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';

export default {
  // 新建/修改单价模式配置接口
  addUnitMode(params) {
    return httpFetch.post(`/api/pcfp/unit/price/option`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 单价模式配置获取
  getUnitModes(params) {
    return httpFetch.get(`/api/pcfp/unit/price/option`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 删除单价模式配置
  deleteUnitMode(unitPriceOptId) {
    return httpFetch.delete(`/api/pcfp/unit/price/option/${unitPriceOptId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 新增单价模式里程规则
  addUnitRule(params) {
    return httpFetch.post(`/api/pcfp/unit/price/rule`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 单价模式里程规则获取
  getUnitRules(params) {
    return httpFetch.get(`/api/pcfp/unit/price/rule`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 删除单价模式里程规则
  deleteUnitRules(unitPriceRuleOptId) {
    return httpFetch.delete(`/api/pcfp/unit/price/rule/${unitPriceRuleOptId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  addLadderMode(params) {
    return httpFetch.post(`/api/pcfp/step/option`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 获取阶梯模式配置
  getLadderModes(params) {
    return httpFetch.get(`/api/pcfp/step/option`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 删除单价模式配置
  deleteLadderMode(stepOptId) {
    return httpFetch.delete(`/api/pcfp/step/option/${stepOptId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },
  // 新增阶梯模式补贴金额计算规则
  addLadderRule(params) {
    return httpFetch.post(`/api/pcfp/step/mileage`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },
  // 获取阶梯模式补贴金额计算规则
  getLadderRules(params) {
    return httpFetch.get(`/api/pcfp/step/mileage`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 删除阶梯模式补贴金额计算规则
  deleteLadderRule(stepMileageOptId) {
    return httpFetch.delete(`/api/pcfp/step/mileage/${stepMileageOptId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },

  // 新增阶梯模式下的规则
  addLadderModeRule(params) {
    return httpFetch.post(`/api/pcfp/step/mileage/rule`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },
  // 获取阶梯模式下所有规则
  getLadderModeRuleLists(params) {
    return httpFetch.get(`/api/pcfp/step/mileage/rule`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },
  // 删除阶梯模式下的规则
  deleteLadderModeRule(id) {
    return httpFetch.delete(`/api/pcfp/step/mileage/rule/${id}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  },
  // 获取阶梯模式规则的详情
  getLadderModeRuleDetail(stepMileageOptId) {
    return httpFetch.get(`/api/pcfp/step/mileage/${stepMileageOptId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      });
  }

};
